function f_segregation_plot_softhard(new_tar,new_noise,F_centers,Combined_dual,L_or_R,rad)

% PlotF = [8 20 40 80]; % 40 ms
titles='ABCDEFGH';KK = {'(‒60^{\circ}&+60^{\circ})','(‒15^{\circ}&+15^{\circ})','(‒5^{\circ}&+5^{\circ})'};
% PlotF = [32 80 160 320]; % 160 ms
fs = 32.1e3; % this is the one for the 3D3A database
% rad = 0.3;% official 0.3

f1=figure('position',[100 400 970 220]);
f2=figure('position',[100 100 250 220]);
f3=figure('position',[100 100 250 220]);
x1=Combined_dual(:,1);
x2=Combined_dual(:,2);
nfft = round(40e-3*fs)
win = hamming(nfft,'periodic');
Combined_mono = sum(Combined_dual,2);

figure(f1)
subplot(131)
stft(new_tar(:,1),fs,'Window',win,'FFTLength',nfft);
ylim([0 5]);title('A. Spectrogram, Target')
colormap('jet')

subplot(132)
stft(new_noise(1:length(new_tar),1),fs,'Window',win,'FFTLength',nfft);
ylim([0 5]);title('B. Spectrogram, Noise')
colormap('jet')

subplot(133)
stft(x1,fs,'Window',win,'FFTLength',nfft);
ylim([0 5]);title('C. Spectrogram, Target + Noise')
colormap('jet')

for isoft=1:2
    if isoft==1
        soft_hard=0
    else
        soft_hard=0.2
    end
    [SL,Fmask,Tsig] = stft(x1,fs,'Window',win,'FFTLength',nfft);
    % % % % There are 1284 (nfft=1284) frequencies in the stft, with 642 being
    % nonredundant.
    SR = stft(x2,fs,'Window',win,'FFTLength',nfft);
    Combined_stft = stft(Combined_mono,fs,'Window',win,'FFTLength',nfft);
    size(Combined_stft)
    % sdf0
    freqs = (1:(nfft/2))./(nfft/2).*fs/2;
    SL = SL(end/2+1:end,:);
    SR = SR(end/2+1:end,:);
    B_mask = ones(size(SL));
    %      normalization:
    % [SL1,SR1]=Normalize(SL,SR);
    fcount = 0;
    [SL1,SR1]=Normalize_Both(SL,SR,L_or_R);
    for ifreql = 1:length(freqs)/2
        freq = freqs(ifreql);
        %     X_P = [real(SR1(ifreql,:))' imag(SR1(ifreql,:))'];
        if L_or_R ==2 % old
            X_P = [real(SR1(ifreql,:))' imag(SR1(ifreql,:))'];
        else
            X_P = [real(SL1(ifreql,:))' imag(SL1(ifreql,:))'];
        end
        for i_time=1:length(X_P)
            % B_mask(ifreql,i_time)=1;
            dist = sqrt((X_P(i_time,1)-F_centers(ifreql,1)).^2 + (X_P(i_time,2)-F_centers(ifreql,2)).^2);
            if dist < rad
                B_mask(ifreql,i_time)=soft_hard;
            end
        end


    end
    full_mask = [flipud(B_mask); B_mask];

    if isoft==1
        figure(f2)
    else
        figure(f3)
    end
    % subplot(1,3,isoft+1)
    contourf(Tsig,Fmask./1000,full_mask,'edgecolor','none');
    ylim([0 5]);
    xlabel('Time (s)');ylabel('Frequency (kHz)');colorbar
    caxis([0 1])
    colormap('gray')

    if isoft==1
        title('D. Hard Mask')
    else
        title('E. Soft Mask')
        % exportgraphics(gcf, 'BB_Figure4_mask.png', 'Resolution', 600,'ContentType', 'vector')

    end
    clear SR SL SL1 SR1
end
% out.reconstructed = real(istft(Combined_stft.*full_mask,fs,'Window',win,'FFTLength',nfft));
% out.freqs = freqs;


exportgraphics(f1, 'F41.png', 'Resolution', 600,'ContentType', 'vector')
exportgraphics(f2, 'F42.png', 'Resolution', 600,'ContentType', 'vector')
exportgraphics(f3, 'F43.png', 'Resolution', 600,'ContentType', 'vector')